package org.he.auth.service.impl;

import org.he.auth.domain.EmployeeRole;
import org.he.auth.dto.EmployeeRoleDTO;
import org.he.auth.mapper.EmployeeRoleMapper;
import org.he.auth.service.IEmployeeRoleService;
import org.he.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author he
 * @since 2023-12-02
 */
@Service
public class EmployeeRoleServiceImpl extends BaseServiceImpl<EmployeeRole> implements IEmployeeRoleService {
    @Autowired
    private EmployeeRoleMapper employeeRoleMapper;
    @Override
    public List<Long> queryRoleById(Long id) {
        return employeeRoleMapper.queryRoleById(id);
    }

    @Override
    public void saveRole(EmployeeRoleDTO dto) {
        employeeRoleMapper.deleteRole(dto.getId());

        if (dto.getRoles().size() != 0){
            employeeRoleMapper.saveRole(dto);
        }
    }
}
